<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateProjectCapacityReportTable extends AbstractMigration
{
    public function up()
    {
        $this->table('project_capacity_report', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '产能上报表'])
            ->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '主键ID'])
            ->addColumn('project_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '项目id'])
            ->addColumn('tenant_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '租户id'])
            ->addColumn('uk', 'string', ['null' => false, 'default' => '', 'limit' => 128, 'comment' => '唯一值'])
            ->addColumn('group_uk', 'string', ['null' => false, 'default' => '', 'limit' => 128, 'comment' => '合并分类组别唯一值'])
            ->addColumn('step_category_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '分类id'])
            ->addColumn('number', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '数量'])
            ->addColumn('number_logic', 'string', ['null' => false, 'default' => '', 'limit' => 128, 'comment' => '数量逻辑类型'])
            ->addColumn('report_month', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '上报年度月份',])
            ->addColumn('created', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '创建时间',])
            ->addColumn('created_by', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '创建人',])
            ->addColumn('updated', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '更新时间',])
            ->addColumn('updated_by', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '更新人',])
            ->addIndex(['project_id', 'step_category_id'], ['type' => 'normal', 'name' => 'idx_project_step_category'])
            ->save();
    }

    public function down()
    {
        $this->table('project_capacity_report')->drop()->save();
    }

}
